<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>麦知网——学问有余，可为人师</title>

<!-- Bootstrap core CSS -->
<link href="../css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="../css/non-responsive.css" rel="stylesheet">
<link href="../css/font-awesome.min.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
<link href="../css/mes_talk.css" rel="stylesheet">    
 
</head>
<body>
	{% include 'public/common/header.html' %}
<div class="container" style="margin-top:45px">
		<div class="row">
			<div class="col-xs-12">
				<!--<div class="mes_title">
					<div class="pull-right"><button type="button" class="btn btn-primary">显示全部</button></div>
					<div class="clearfix"></div>
				</div>-->
				<div class="m_t_con">
					<a href="javascript:void(0)" data-toggle="modal" data-target="#myModal"><h4><span class="glyphicon glyphicon-send"></span> 回复他</h4></a>

					<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					  <div class="modal-dialog">
					    <div class="modal-content">
					      <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					        <h4 class="modal-title">回复私信</h4>
					      </div>
					      <div class="modal-body">
					        <textarea class="form-control" id="message" style="height:120px"></textarea>
					      </div>
					      <div class="modal-footer">
					      	<span id='messageresult{{i.8}}'></span>
					        <button type="button" onclick="connected({{talkto}})" class="btn btn-primary">发送</button>
					      </div>
					    </div><!-- /.modal-content -->
					  </div><!-- /.modal-dialog -->
					</div><!-- /.modal -->

<!--  一条别人发给我 循环开始处 -->
					{% for m in messages %}
					{% ifnotequal m.0 info.user_id %}
					<div class="m_t_atalk">
						<div class="pull-left">
							<div class="m_t_img"><a href="{% url 'users:home' m.0 %}"><img class="img-circle" src="{{m.3}}/{{m.2}}" width="100%"/></a></div>
							<div class="m_t_name"><a href="{% url 'users:home' m.0 %}">{{m.1}}</a></div>
						</div>
						<div class="pull-left"><div class="topdirection"></div></div>
						<div class="pull-left m_t_content">
							<div class="pull-right time">{{m.5|date:"Y-m-d H:i:s"}}</div>
							<div class="clearfix"></div>
							<div>{{m.4}}</div>
						</div>
						<div class="clearfix"></div>
					</div>
					
<!--  一条别人发给我 循环结束处 -->

<!--  一条我发给别人 循环开始处 -->{% else %}
					<div class="m_t_atalk">
						<div class="pull-right">
							<div class="m_t_img"><a href="{% url 'users:home' m.0 %}"><img class="img-circle" src="{{m.3}}/{{m.2}}" width="100%"/></a></div>
							<div class="m_t_name"><a href="{% url 'users:home' m.0 %}">{{m.1}}</a></div>
						</div>
						<div class="pull-right"><div class="topdirection2"></div></div>
						<div class="pull-right m_t_content">
							<div class="pull-right time">{{m.5|date:"Y-m-d H:i:s"}}</div>
							<div class="clearfix"></div>
							<div>{{m.4}}</div>
						</div>
						<div class="clearfix"></div>
					</div>
<!--  一条我发给别人 循环结束处 -->{% endifnotequal %}
							{% endfor %}
					<ul class="pager">
					{% if messages.has_previous %}
					  <li><a href="?page={{ messages.previous_page_number }}">&larr;上一页</a></li>
					{% endif %}
					共 {{ messages.number }} 页  第 {{ messages.paginator.num_pages }} 页.
					{% if messages.has_next %}
					  <li><a href="?page={{ message.next_page_number }}">下一页&rarr;</a></li>
					{% endif %}
					</ul>
				</div>
			</div>
		</div>
</div>
	
	
	
	
	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
	<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
	<script src="../js/logout.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
	<script type="text/javascript">
	var xmlHttp; 

	function createXMLRequest(){
		if(window.XMLHttpRequest){
			xmlHttp=new XMLHttpRequest();
		} else {
			xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
		}
	}
	//添加私信
	function connected(id){
		createXMLRequest();                       
		var message=document.getElementById("message").value;
		var messageurl="/users/message/?message="+message+"&to="+id;
		xmlHttp.open('get',messageurl);
		xmlHttp.onreadystatechange=function () {
			if(xmlHttp.readyState==4 && xmlHttp.status==200){
				$("#myModal").modal('hide');
				//result=document.getElementById('messageresult'+id);
				//result.innerHTML=xmlHttp.responseText;
				//result.style.color='orange';
				window.location.reload();
			};
		};
		xmlHttp.send(); 
	}

	</script>
</body>
</html>